﻿using System;
using System.Configuration;

namespace NsbExtensions.Configuration
{
    public class EndpointManagerConfiguration : ConfigurationSection
    {
        [ConfigurationProperty("statusReportInterval")]
        public TimeSpan StatusReportInterval
        {
            get { return (TimeSpan) base["statusReportInterval"]; }
            set { base["statusReportInterval"] = value; }
        }

        [ConfigurationProperty("statusReportGracePeriod")]
        public TimeSpan StatusReportGracePeriod
        {
            get { return (TimeSpan) base["statusReportGracePeriod"]; }
            set { base["statusReportGracePeriod"] = value; }
        }

        [ConfigurationProperty("monitorServiceAddress")]
        public string MonitorServiceAddress
        {
            get { return (string) base["monitorServiceAddress"]; }
            set { base["monitorServiceAddress"] = value; }
        }

        [ConfigurationProperty("statusProbes")]
        public EndpointStatusProbeConfigurationCollection StatusProbes
        {
            get { return (EndpointStatusProbeConfigurationCollection) base["statusProbes"]; }
            set { base["statusProbes"] = value; }
        }

        public static EndpointManagerConfiguration GetConfiguration()
        {
            return GetConfiguration("endpointManager");
        }

        public static EndpointManagerConfiguration GetConfiguration(string sectionName)
        {
            return ConfigurationManager.GetSection(sectionName) as EndpointManagerConfiguration;
        }
    }
}